home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Softshoe / Lisa's Mac Parts / Printing / PrintBatch.cp < prev    next >
Text File  |  2000-06-23  |  1KB  |  59 lines

  1. // PrintBatch.cp
  2.  
  3. #ifndef PrintBatch_h
  4. #include "PrintBatch.h"
  5. #endif
  6. #ifndef PrintingError_h
  7. #include "PrintingError.h"
  8. #endif
  9. #ifndef PrintJob_h
  10. #include "PrintJob.h"
  11. #endif
  12.  
  13. bool PrintBatch::batchExists = false;
  14.  
  15. PrintBatch::PrintBatch( const PrintJob& theJob )
  16.   : job( theJob ),
  17.      started( false )
  18.   {
  19.     Assert( !batchExists );
  20.     batchExists = true;
  21.   }
  22.  
  23. PrintBatch::~PrintBatch()
  24.   {
  25.     if ( started )
  26.       {
  27.         PrCloseDoc( &port );
  28.         DebugOSError( PrError() );
  29.       }
  30.     
  31.     Assert( batchExists );
  32.     batchExists = false;
  33.   }
  34.  
  35. void PrintBatch::Start()
  36.   {
  37.     Assert( !started );
  38.     TPPrPort returned = PrOpenDoc( job.PrintHandle(), &port, buffer );
  39.     ThrowPrintingError( PrError() );
  40.     Assert( returned == &port );
  41.     started = true;
  42.   }
  43.  
  44. void PrintBatch::End()
  45.   {
  46.     Assert( started );
  47.     started = false;
  48.     
  49.     PrCloseDoc( &port );
  50.     ThrowPrintingError( PrError() );
  51.     
  52.     if ( job.Spooled() )
  53.       {
  54.         TPrStatus status;
  55.         PrPicFile( job.PrintHandle(), &port, buffer, 0, &status );
  56.         ThrowPrintingError( PrError() );
  57.       }
  58.   }
  59.